package server.config.exception;

import lombok.extern.log4j.Log4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import plug.result.RetResponse;
import plug.result.RetResult;

/**
 * 创建人:    xvzhe
 * 创建时间:
 * 修改时间:
 * 版本:      v1.0
 */
@ControllerAdvice
@Log4j
public class GlobalExceptionHandler {

    @ExceptionHandler(value = BizException.class)
    @ResponseBody
    public RetResult bizExceptionHandler(BizException e) {
        log.error("发生业务异常！原因是：{}", e);
        return RetResponse.makeErrRsp(e.getErrorCode(), e.getErrorMsg());
    }
}
